const dataSources: any = {
  list: [],
  dataHandler: null,
};

const dataSourceMap: any = {};

Array.isArray(
  {
    list: [],
    dataHandler: null,
  }.list,
) &&
  dataSources.list.forEach((config: any) => {
    const dataSource: any = { config: config.data },
      result = {
        code: "",
        msg: "success",
        data: {},
      };

    result.data =
      dataSource.config.type === "array"
        ? {
            items: dataSource?.config?.data,
            total: dataSource?.config?.data?.length,
          }
        : dataSource?.config?.data;
    dataSourceMap[config.name] = dataSource;

    dataSource.load = () => Promise.resolve(result);
  });

export default dataSourceMap;
